<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
  <script>
      function arrToObj(arr){
          let obj = {};
          for (let i = 0; i < arr.length; i++) {
              if (!obj.hasOwnProperty(arr[i])){
                  obj[arr[i]] = 1;
              }else{
                  obj[arr[i]]++;
              }
          }
          return obj;
      }

      console.log(arrToObj(['a','a','a','b','b','c','c','c','c','d','d','d','d'] ));
  </script>
</body>
</html>